import os
from PIL import Image

path = 'images' #原始图片文件夹
out_path = 'output' #加好的图片文件夹
logo = Image.open('logo.png')
for filename in os.listdir(path): #循环文件夹下的图片
    image_path = path + '/' + filename #拼接文件夹和图片名称
    image = Image.open(image_path) 
    x = image.width - logo.width - 5
    y = image.height - logo.height - 5
    image.paste(logo, (x, y))
    image.save(out_path + '/' + filename) #把加好的水印的图片输出到目标目录下